/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package conventus;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

/**
 *
 * @author Douglas Tybel
 */
@Entity
@Table(name = "atas", catalog = "conventus", schema = "")
@NamedQueries({
    @NamedQuery(name = "Atas.findAll", query = "SELECT a FROM Atas a"),
    @NamedQuery(name = "Atas.findByCodAta", query = "SELECT a FROM Atas a WHERE a.codAta = :codAta"),
    @NamedQuery(name = "Atas.findByCodSituacao", query = "SELECT a FROM Atas a WHERE a.codSituacao = :codSituacao"),
    @NamedQuery(name = "Atas.findByAssunto", query = "SELECT a FROM Atas a WHERE a.assunto = :assunto"),
    @NamedQuery(name = "Atas.findByLocal", query = "SELECT a FROM Atas a WHERE a.local = :local"),
    @NamedQuery(name = "Atas.findByDatInicio", query = "SELECT a FROM Atas a WHERE a.datInicio = :datInicio"),
    @NamedQuery(name = "Atas.findByDatFinal", query = "SELECT a FROM Atas a WHERE a.datFinal = :datFinal")})
public class Atas implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "COD_ATA")
    private Integer codAta;
    @JoinColumn(name="COD_SITUACAO",referencedColumnName="COD_SITUACAO")
    @ManyToOne
    private Situacoes codSituacao;
    @Basic(optional = false)
    @Column(name = "ASSUNTO")
    private String assunto;
    @Basic(optional = false)
    @Column(name = "LOCAL")
    private String local;
    @Basic(optional = false)
    @Column(name = "DAT_INICIO")
    @Temporal(TemporalType.TIMESTAMP)
    private Date datInicio;
    @Basic(optional = false)
    @Column(name = "DAT_FINAL")
    @Temporal(TemporalType.TIMESTAMP)
    private Date datFinal;

    @OneToMany(mappedBy = "codAta")
    private Collection<Topicos> topicosCollection;
    @OneToMany(mappedBy = "codAta")
    private List<AtasMembros> atasMembrosList;

    public Atas() {
    }

    public Atas(Integer codAta) {
        this.codAta = codAta;
    }

    public Atas(Integer codAta, Situacoes codSituacao, String assunto, String local, Date datInicio, Date datFinal) {
        this.codAta = codAta;
        this.codSituacao = codSituacao;
        this.assunto = assunto;
        this.local = local;
        this.datInicio = datInicio;
        this.datFinal = datFinal;
    }

    public Integer getCodAta() {
        return codAta;
    }

    public void setCodAta(Integer codAta) {
        Integer oldCodAta = this.codAta;
        this.codAta = codAta;
        changeSupport.firePropertyChange("codAta", oldCodAta, codAta);
    }

    public Situacoes getCodSituacao() {
        return codSituacao;
    }

    public void setCodSituacao(Situacoes codSituacao) {
        Situacoes oldCodSituacao = this.codSituacao;
        this.codSituacao = codSituacao;
        changeSupport.firePropertyChange("codSituacao", oldCodSituacao, codSituacao);
    }

    public String getAssunto() {
        return assunto;
    }

    public void setAssunto(String assunto) {
        String oldAssunto = this.assunto;
        this.assunto = assunto;
        changeSupport.firePropertyChange("assunto", oldAssunto, assunto);
    }

    public String getLocal() {
        return local;
    }

    public void setLocal(String local) {
        String oldLocal = this.local;
        this.local = local;
        changeSupport.firePropertyChange("local", oldLocal, local);
    }

    public Date getDatInicio() {
        return datInicio;
    }

    public void setDatInicio(Date datInicio) {
        Date oldDatInicio = this.datInicio;
        this.datInicio = datInicio;
        changeSupport.firePropertyChange("datInicio", oldDatInicio, datInicio);
    }

    public Date getDatFinal() {
        return datFinal;
    }

    public void setDatFinal(Date datFinal) {
        Date oldDatFinal = this.datFinal;
        this.datFinal = datFinal;
        changeSupport.firePropertyChange("datFinal", oldDatFinal, datFinal);
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (codAta != null ? codAta.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Atas)) {
            return false;
        }
        Atas other = (Atas) object;
        if ((this.codAta == null && other.codAta != null) || (this.codAta != null && !this.codAta.equals(other.codAta))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "conventus.Atas[ codAta=" + codAta + " ]";
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }

    public Collection<Topicos> getTopicosCollection() {
        return topicosCollection;
    }

    public void setTopicosCollection(Collection<Topicos> topicosCollection) {
        this.topicosCollection = topicosCollection;
    }
    
}
